<?php
class DateUtility
{
    public static function today($format = 'Y-m-d')
	{
		return date($format);
	}
	
	public static function tomorrow($format = 'Y-m-d')
	{
		return date($format, strtotime('tomorrow'));
	}
	
	public static function yesterday($format = 'Y-m-d')
	{
		return date($format, strtotime('yesterday'));
	}
    
    public static function next($date, $interval, $format = 'Y-m-d')
    {
        return date($format, strtotime(sprintf('%s +%d day', $date, $interval)));
    }

    public static function ago($date, $interval, $format = 'Y-m-d')
    {
        return date($format, strtotime(sprintf('%s -%d day', $date, $interval)));
    }
    
    public static function convertFormat($oldDate, $oldFormat, $newFormat)
    {
        $newDate = DateTime::createFromFormat($oldFormat, $oldDate);
        if(!$newDate)
        {
            return false;
        }
        return $newDate->format($newFormat);
    }
}
